#############################################################################################
#                                                                                           #
#                   Copyright 2010-2013 Ning, Inc.                                          #
#                   Copyright 2014 Groupon, Inc.                                            #
#                   Copyright 2014 The Billing Project, LLC                                 #
#                                                                                           #
#      The Billing Project licenses this file to you under the Apache License, version 2.0  #
#      (the "License"); you may not use this file except in compliance with the             #
#      License.  You may obtain a copy of the License at:                                   #
#                                                                                           #
#          http://www.apache.org/licenses/LICENSE-2.0                                       #
#                                                                                           #
#      Unless required by applicable law or agreed to in writing, software                  #
#      distributed under the License is distributed on an "AS IS" BASIS, WITHOUT            #
#      WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the            #
#      License for the specific language governing permissions and limitations              #
#      under the License.                                                                   #
#                                                                                           #
#############################################################################################


#
#                       DO NOT EDIT!!!
#    File automatically generated by killbill-java-parser (git@github.com:killbill/killbill-java-parser.git)
#


module Killbill
  module Plugin
    module Model

      java_package 'org.killbill.billing.util.nodes'
      class NodeInfo

        include org.killbill.billing.util.nodes.NodeInfo

        attr_accessor :node_name, :boot_time, :last_updated_date, :killbill_version, :api_version, :platform_version, :common_version, :plugin_api_version, :plugin_info

        def initialize()
        end

        def to_java()
          # conversion for node_name [type = java.lang.String]
          @node_name = @node_name.to_s unless @node_name.nil?

          # conversion for boot_time [type = org.joda.time.DateTime]
          if !@boot_time.nil?
            @boot_time =  (@boot_time.kind_of? Time) ? DateTime.parse(@boot_time.to_s) : @boot_time
            @boot_time = Java::org.joda.time.DateTime.new(@boot_time.to_s, Java::org.joda.time.DateTimeZone::UTC)
          end

          # conversion for last_updated_date [type = org.joda.time.DateTime]
          if !@last_updated_date.nil?
            @last_updated_date =  (@last_updated_date.kind_of? Time) ? DateTime.parse(@last_updated_date.to_s) : @last_updated_date
            @last_updated_date = Java::org.joda.time.DateTime.new(@last_updated_date.to_s, Java::org.joda.time.DateTimeZone::UTC)
          end

          # conversion for killbill_version [type = java.lang.String]
          @killbill_version = @killbill_version.to_s unless @killbill_version.nil?

          # conversion for api_version [type = java.lang.String]
          @api_version = @api_version.to_s unless @api_version.nil?

          # conversion for platform_version [type = java.lang.String]
          @platform_version = @platform_version.to_s unless @platform_version.nil?

          # conversion for common_version [type = java.lang.String]
          @common_version = @common_version.to_s unless @common_version.nil?

          # conversion for plugin_api_version [type = java.lang.String]
          @plugin_api_version = @plugin_api_version.to_s unless @plugin_api_version.nil?

          # conversion for plugin_info [type = java.lang.Iterable]
          tmp = java.util.ArrayList.new
          (@plugin_info || []).each do |m|
            # conversion for m [type = org.killbill.billing.osgi.api.PluginInfo]
            m = m.to_java unless m.nil?
            tmp.add(m)
          end
          @plugin_info = tmp
          self
        end

        def to_ruby(j_obj)
          # conversion for node_name [type = java.lang.String]
          @node_name = j_obj.node_name

          # conversion for boot_time [type = org.joda.time.DateTime]
          @boot_time = j_obj.boot_time
          if !@boot_time.nil?
            fmt = Java::org.joda.time.format.ISODateTimeFormat.date_time_no_millis # See https://github.com/killbill/killbill-java-parser/issues/3
            str = fmt.print(@boot_time)
            @boot_time = DateTime.iso8601(str)
          end

          # conversion for last_updated_date [type = org.joda.time.DateTime]
          @last_updated_date = j_obj.last_updated_date
          if !@last_updated_date.nil?
            fmt = Java::org.joda.time.format.ISODateTimeFormat.date_time_no_millis # See https://github.com/killbill/killbill-java-parser/issues/3
            str = fmt.print(@last_updated_date)
            @last_updated_date = DateTime.iso8601(str)
          end

          # conversion for killbill_version [type = java.lang.String]
          @killbill_version = j_obj.killbill_version

          # conversion for api_version [type = java.lang.String]
          @api_version = j_obj.api_version

          # conversion for platform_version [type = java.lang.String]
          @platform_version = j_obj.platform_version

          # conversion for common_version [type = java.lang.String]
          @common_version = j_obj.common_version

          # conversion for plugin_api_version [type = java.lang.String]
          @plugin_api_version = j_obj.plugin_api_version

          # conversion for plugin_info [type = java.lang.Iterable]
          @plugin_info = j_obj.plugin_info
          tmp = []
          (@plugin_info.nil? ? [] : @plugin_info.iterator).each do |m|
            # conversion for m [type = org.killbill.billing.osgi.api.PluginInfo]
            m = Killbill::Plugin::Model::PluginInfo.new.to_ruby(m) unless m.nil?
            tmp << m
          end
          @plugin_info = tmp
          self
        end

      end
    end
  end
end
